﻿using System;
using System.Collections.Generic;
using System.Text;
using MDK;

namespace InvisibleCollapse
{
    class MovingParticle : Particle
    {
        public double angle;

        public double l = 0; // путь

        public MovingParticle(double angle, double Q, double E, double P, double B)
        {
            this.Q = Q;
            this.E = E;
            this.p = P;

            this.angle = angle;

            CountMassInvariant();

            this.vx = this.V * Math.Sin(this.angle);
            this.vy = this.V * Math.Cos(this.angle);
            
            this.B = B;
        }

        public void ReCount()
        {
            this.V = this.p / this.m;

            this.vx = this.V * Math.Sin(this.angle);
            this.vy = this.V * Math.Cos(this.angle);

            this.l = 0;
        }

        public void Move()
        {
            double Fl = Q * V *B/ m;
            double v0 = V;
            
            V = Math.Sqrt(v0 * v0 + Fl * Fl);
            
            l += V / 10;
            V += Math.Pow(Math.E, l / V);
                        
            angle -= Math.Tan(Fl / v0);

            double angl = Math.PI / 2 - angle;

            vx = (V * Math.Cos(angl));
            vy = (V * Math.Sin(angl));

            x += (float) vx;
            y -= (float) vy;

        }


        public double B;
    }
}
